package com.x.ant.service;

import com.x.ant.dao.TaskDao;
import com.x.ant.manage.TaskManage;
import com.x.ant.model.Bill;
import com.x.ant.model.Task;
import com.x.framework.exception.BusinessException;
import com.x.framework.exception.ExceptionCode;
import com.x.framework.service.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class TaskService extends BaseService {
    @Autowired
    private TaskManage taskManage;

    @Autowired
    private TaskDao taskDao;

    public int selectTaskNum(Task task) {
        try {
            return taskDao.selectTaskNum(task);
        } catch (Exception e){
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

    public List<Task> selectTaskList(Task task) {
        try {
            return taskDao.selectTaskList(task);
        } catch (Exception e){
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

    public List<int[]> selectBillTruckSum(Bill bill) {
        try {
            return taskDao.selectBillTruckSum(bill);
        } catch (Exception e){
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

    public void insertTask(Task task) {
        try {
            taskManage.insertTask(task);
        } catch (Exception e){
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

    public void updateTask(Task task) {
        try {
            taskManage.updateTask(task);
        } catch (Exception e){
            throw new BusinessException(ExceptionCode.EXCEPTION_CODE0000, e);
        }
    }

}
